<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //占位图
        //先显示占位图
        //派一个代理对象去请求真实的图片地址
        //交给这个对象
        var myImage = (function(){
            var imgNode = document.createElement('img');
            document.body.appendChild(imgNode);

            return{
                setSrc:function(src){
                    console.log(src,'5666');
                    imgNode.src = src;
                }
            }
        })()
        var proxyImage =(function(){
            //闭合空间
            
            var image = new Image();//Dom 代理对象
            image.onload = function(){
              
                myImage.setSrc (this.src);    
            }
            
            return {
                setSrc: function(src){
                    // console.log(src);
                    myImage.setSrc('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F458412ef0894476c376deb206e089b27160f46ba4452-nMT6Xd_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633315734&t=5920234e8cd4c299436c724431d894e6')
                    console.log(src);
                   
                    image.src = src;
                    // src 变量 scope
                }
            }
        })()
        proxyImage.setSrc('https://img2.baidu.com/it/u=4251059536,2165781887&fm=26&fmt=auto&gp=0.jpg')
    </script>
</body>
</html>